package com.think.teaching.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.think.teaching.model.CourseTeacher;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 课程和老师关联表 Mapper 接口
 * </p>
 *
 * @author think
 * @since 2020-08-12
 */
public interface CourseTeacherMapper extends BaseMapper<CourseTeacher> {

	@Select("<script>" +
			"SELECT " +
			"a.id,a.teacher_id," +
			"a.course_id,b.user_id," +
			"b.titles," +
			"b.`name`," +
			"b.description, " +
			"a.order " +
			"FROM course_teacher a LEFT JOIN teacher_info b ON b.id = a.teacher_id " +
			"WHERE " +
			"a.course_id=#{id} and b.delflag=0"+
			"<if test='withoutBan==true'> and b.state=1</if>"+
			" ORDER BY `order`"+
			"</script>"
	)
	List<Map<String, Object>> GetTeachersByCourseId(@Param("id") Integer id,
													@Param("withoutBan") Boolean withoutBan);
}
